package {{project.group}}.{{project.artifact}};

import com.jfinal.config.Constants;
import com.jfinal.config.Handlers;
import com.jfinal.config.Interceptors;
import com.jfinal.config.JFinalConfig;
import com.jfinal.config.Plugins;
import com.jfinal.config.Routes;
import com.jfinal.kit.PropKit;
{{#datasource.url}}
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.druid.DruidPlugin;
{{/datasource.url}}
import com.jfinal.json.MixedJsonFactory;
import com.jfinal.template.Engine;
 
public class AppConfig extends JFinalConfig {
 
    public void configConstant(Constants me) {
       PropKit.use("config.txt");
       me.setDevMode(true);
       me.setJsonFactory(new MixedJsonFactory());
    }
    
    public void configRoute(Routes me) {
       // jfinal 4.9.03 版新增了路由扫描功能，不必手动添加路由
       // me.add("/hello", HelloController.class);
       
       // 使用路由扫描，参数 "demo." 表示只扫描 demo 包及其子包下的路由
       me.scan("{{project.group}}.{{project.artifact}}");
    }
    
    public void configEngine(Engine me) {}
    public void configPlugin(Plugins me) {
      {{#datasource.url}}
		// 配置C3p0数据库连接池插件
		DruidPlugin druidPlugin = new DruidPlugin(PropKit.get("datasource.url"), PropKit.get("datasource.username"), PropKit.get("datasource.password").trim());
		me.add(druidPlugin);
		
		// 配置ActiveRecord插件
		ActiveRecordPlugin arp = new ActiveRecordPlugin("db", druidPlugin);
		arp.setShowSql(true);
		me.add(arp);
      {{/datasource.url}}
    }
    public void configInterceptor(Interceptors me) {}
    public void configHandler(Handlers me) {}
}